--静肃威能
local jingsuweineng = fk.CreateSkill {
    name = "mcdh_jingsuweineng",
}

jingsuweineng:addEffect(fk.HpChanged,{
    can_trigger=function (self, event, target, player, data)
        if player:hasSkill(jingsuweineng.name) and target == player then
            local events = player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function (e)
            local hp = e.data
            return hp.who == player and not hp.prevented
        end, Player.HistoryTurn)
        return #events == 1 and events[1].id == player.room.logic:getCurrentEvent().id
        end
    end,
    on_cost=function (self, event, target, player, data)
        local room = player.room
        local cards =room:askToCards(player,{min_num = 2,max_num=2,skill_name=jingsuweineng.name,include_equip=true})
        if #cards == 2  then
            event:setCostData(self,cards)
            return true
        end
    end,
    on_use=function (self, event, target, player, data)
        local room = player.room
        local cards = event:getCostData(self)
        local flag = table.every(cards,function (id)
            return Fk:getCardById(id).type ~= Card.TypeBasic
        end)
        room:recastCard(cards,player,jingsuweineng.name)
        if flag and not player.dead then
            local choices = {}
            if player:isWounded() then
                table.insert(choices,"#jingsuweineng-recover")
            end
            if not room.current.dead then
                table.insert(choices,"#jingsuweineng-draw")
            end
            if #choices == 2 then
                if room:askToSkillInvoke(player,{skill_name=jingsuweineng.name,prompt="#jingsuweineng:"..room.current.id}) then
                    room.current:drawCards(4,jingsuweineng.name)
                else
                    room:recover({who = player,num=1,skillName = jingsuweineng.name})
                end
            elseif #choices == 1 then
                    if choices[1] == "#jingsuweineng-recover" then
                        room:recover({who = player,num=1,skillName = jingsuweineng.name})
                    else
                        room.current:drawCards(4,jingsuweineng.name)
                    end
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_jingsuweineng"] = "静肃威能",
    [":mcdh_jingsuweineng"] = "当你的体力每回合首次变化后，你可以重铸两张牌，若重铸牌均为非基本牌，你回复1点体力或令当前回合角色摸四张牌。",
    ["#jingsuweineng"] = "静肃威能: 令%src 摸四张牌，取消则你回复一点体力 ",
}

return jingsuweineng